﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace GUI_Web
{
    public partial class ConfPresen : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Troca(true);
                Session["num"] = "0";
            }
        }

        protected void btnCod_Click(object sender, EventArgs e)
        {            
            if (txtCod.Text == "senha")
            {
                if (Session["num"].ToString() != "0")
                {
                    if (Session["num"].ToString() == "1")
                    {
                        tabelaConfirm.Rows.Add(ev1);
                        link01.Visible = false;
                    }
                    else if (Session["num"].ToString() == "2")
                    {
                        tabelaConfirm.Rows.Add(ev2);
                        link02.Visible = false;
                    }
                }
                tabelaConfirm.Rows.Add(ev1);
                link01.Visible = false;
                clsUtils.Mensagem(this, "Presença confirmada.");
                Troca(true);

                Session.Remove("num");
            }
            else
                clsUtils.Mensagem(this, "Senha inválida.");

            txtCod.Text = "";
        }

        private void Troca(bool chave)
        {
            divTb.Visible = chave;
            divCod.Visible = !chave;
        }

        protected void link01_Click(object sender, EventArgs e)
        {
            Troca(false);
            Session["num"] = "1";
        }

        protected void btnVolta_Click(object sender, EventArgs e)
        {
            Troca(true);
        }

        protected void link02_Click(object sender, EventArgs e)
        {
            Troca(false);
            Session["num"] = "2";
        }
    }
}